package com.pickme.food.controller;

import com.pickme.food.common.Res;
import com.pickme.food.pojo.Stats;
import com.pickme.food.service.inte.StatsService;
import io.swagger.annotations.Api;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.format.annotation.DateTimeFormat;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.Date;
import java.util.List;

/**
 * 经营汇总
 */

@Api(tags = "经营汇总")
@Slf4j
@RestController
@RequestMapping("/stats")
public class StatsController {

    @Autowired
    private StatsService statsService;

    /**
     * 查询指定日期范围内的统计数据
     * @param beginTime
     * @param endTime
     */
    @GetMapping
    public Res<List<Stats>> getStats(@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss") Date beginTime,
                                     @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss") Date endTime
    ) {
        List<Stats> statsList = statsService.ListStats(beginTime, endTime);
        return Res.success(statsList);
    }
}
